home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
User's Choice Windows CD
/
User's Choice Windows CD (CMS Software)(1993).iso
/
win_q_t
/
trem.zip
/
WRITE.C
< prev
Wrap
Text File
|
1991-05-11
|
4KB
|
136 lines
/************************************************************************
*
* Copyright (c) 1991 Microsoft Corporation. All Rights Reserved.
*
*-----------------------------------------------------------------------
*
* Project: Windows Terminal Example
*
* Module: write.c
*
* Author: Bryan A. Woodruff (baw)
*
*
* Remarks: This controls the writing of characters to the "screen".
*
* Revisions:
* 01.00.000 5/ 9/91 baw Wrote it.
*
************************************************************************/
#include "terminal.h"
/************************************************************************
* BOOL WriteTerminalByte( HWND hWnd, BYTE bIn )
*
* Description:
* Writes character to terminal screen. Nothing fancy - just
* straight TTY.
*
* Comments:
* 5/ 9/91 baw Wrote it.
*
************************************************************************/
BOOL WriteTerminalByte( HWND hWnd, BYTE bIn )
{
LOCALHANDLE hTermInfo ;
NPTERMINFO npTermInfo ;
RECT rect ;
hTermInfo = GetWindowWord( hWnd, GWW_TERMINFO ) ;
if (NULL == (npTermInfo = (NPTERMINFO) LocalLock( hTermInfo )))
return ( FALSE ) ;
switch (bIn)
{
case ASCII_BEL:
// Bell
MessageBeep( 0 ) ;
break ;
case ASCII_BS:
// Backspace
if (npTermInfo -> nColumn > 0)
npTermInfo -> nColumn -- ;
MoveTerminalCursor( hWnd ) ;
break ;
case ASCII_CR:
// Carriage return
npTermInfo -> nColumn = 0 ;
MoveTerminalCursor( hWnd ) ;
if (!npTermInfo -> fNewLine)
break;
// fall through
case ASCII_LF:
// Line feed
if (npTermInfo -> nRow++ == MAXROWS - 1)
{
_fmemmove( (LPSTR) (npTermInfo -> abScreen),
(LPSTR) (npTermInfo -> abScreen + MAXCOLS),
(MAXROWS - 1) * MAXCOLS ) ;
_fmemset( (LPSTR) (npTermInfo -> abScreen + (MAXROWS - 1) * MAXCOLS),
' ', MAXCOLS ) ;
InvalidateRect( hWnd, NULL, FALSE ) ;
npTermInfo -> nRow-- ;
}
MoveTerminalCursor( hWnd ) ;
break ;
default:
*(LPSTR)(npTermInfo -> abScreen + npTermInfo -> nRow * MAXCOLS +
npTermInfo -> nColumn) = bIn ;
rect.left = (npTermInfo -> nColumn * npTermInfo -> xChar) -
npTermInfo -> xOffset ;
rect.right = rect.left + npTermInfo -> xChar ;
rect.top = (npTermInfo -> nRow * npTermInfo -> yChar) -
npTermInfo -> yOffset ;
rect.bottom = rect.top + npTermInfo -> yChar ;
InvalidateRect( hWnd, &rect, FALSE ) ;
// Line wrap
if (npTermInfo -> nColumn < MAXCOLS - 1)
npTermInfo -> nColumn++ ;
else if (npTermInfo -> fAutoWrap)
{
WriteTerminalByte( hWnd, ASCII_CR ) ;
WriteTerminalByte( hWnd, ASCII_LF ) ;
}
break;
}
LocalUnlock( hTermInfo ) ;
return ( TRUE ) ;
} /* end of WriteTerminalByte() */
/************************************************************************
* BOOL WriteTerminalBlock( HWND hWnd, LPSTR lpBlock, int nLength )
*
* Description:
* Writes a block to the terminal screen.
* Calls WriteTerminalByte().
*
* Comments:
* 5/10/91 baw Wrote it.
*
************************************************************************/
BOOL WriteTerminalBlock( HWND hWnd, LPSTR lpBlock, int nLength )
{
int i ;
for (i = 0; i < nLength; i++)
WriteTerminalByte( hWnd, lpBlock[i] ) ;
return ( TRUE ) ;
} /* end of WriteTerminalBlock() */
/************************************************************************
* End of File: write.c
************************************************************************/